cmake_minimum_required(VERSION 3.8)
project(cpp_can)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

#添加项目中的include文件夹路径
include_directories(include)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)

# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(cpp_can_pub src/cpp_can_pub.cpp)
target_include_directories(can_demo_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)
target_compile_features(can_demo_node PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
ament_target_dependencies(
  can_demo_node
  "rclcpp"
  "std_msgs"
)
# 添加Link
target_link_libraries(can_demo_node 
  ${PROJECT_SOURCE_DIR}/lib/libcontrolcan.so
)

install(TARGETS can_demo_node
  DESTINATION lib/${PROJECT_NAME}
)
install(
    DIRECTORY lib/                       # 发现你项目中的lib中所有的文件
    DESTINATION lib/${PROJECT_NAME}      # 拷贝到install目录中
)
install(TARGETS can_demo_node 
    RUNTIME DESTINATION lib/${PROJECT_NAME}    # 程序运行的时候调用install中的路径
)


if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
